/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.vod.gauss.operations;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 
 * @author drazanakoto
 */
public class GF256 {

	private int[][] tab;
	private final int SIZE = 256;

	public GF256() {
		tab = new int[SIZE][SIZE];
		String[] tmp;
		try {

			InputStream is = GF256.class.getResourceAsStream("tableau.csv");
			BufferedReader br = new BufferedReader(new InputStreamReader(is));
			String line;
			int cpt = 0;
			while ((line = br.readLine()) != null) {
				tmp = line.split(";");
				for (int i = 0; i < tmp.length; i++) {
					tab[cpt][i] = Integer.valueOf(tmp[i]);
				}
				cpt++;
			}
		} catch (Exception ex) {
		}
	}

	/**
	 * 
	 * @param ligne
	 * @param colonne
	 * @return
	 */
	public int multiplication(int ligne, int colonne) {
		return tab[colonne][ligne];
	}

	/**
	 * 
	 * @param dividende
	 * @param diviseur
	 * @return
	 */
	public int division(int dividende, int diviseur) {
		int[] tmp = tab[diviseur];
		int result = 0;
		for (int i = 0; i < tmp.length; i++) {
			if (tmp[i] == dividende) {
				return i;
			}
		}
		return result;
	}
}
